package com.jerkin.dubbo.service;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.dubbo.remoting.TimeoutException;
import com.alibaba.dubbo.rpc.RpcException;

import com.jerkin.dubbo.context.ExceptionHandleTag;
import com.jerkin.facade.StudentFacade;
import org.springframework.stereotype.Component;

/**
 * @version V1.0
 * @ClassName: AccountExt
 * @Description:
 * @author: huhongzhi
 * @date: 2020/8/3 21:33
 */
@Component
public class AccountExt {
    @Reference(version = "1.0.0")
    private StudentFacade studentFacade;

    @ExceptionHandleTag(exceptions = {TimeoutException.class,
            RpcException.class,NullPointerException.class},referenceMethod = "accountExt#updateRollBack")
    public void update(Long id, Long amount) throws InterruptedException {
        studentFacade.update(id,amount);
    }

    public void updateRollBack(Long id, Long amount) throws InterruptedException {
        studentFacade.update(id,-1*amount);
    }


}
